import IToast from '@/components/msg/IToast.vue';
import { createApp, h } from 'vue';
const toastPlugin = {
    install(app: any) {
        const container = document.createElement('div');
        container.id = 'toast-container';
        document.body.appendChild(container);
        const toastApp = createApp({
            render() {
                return h(IToast, { ref: 'toastRef' });
            }
        });
        const vm = toastApp.mount(container);
        const toastInstance: any = vm.$refs.toastRef;
        app.config.globalProperties.$toast = (msg: string, type: string) => {
            toastInstance.showToast(msg, type);
        };
    }
};

export default toastPlugin;    